package util.file;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


public class MultiProtocolFile implements IMultiProtocolFile
{
	protected IMultiProtocolFile impl;
	
	public MultiProtocolFile(String path) throws IOException
	{
//		if (path.startsWith("smb://"))
//		{			
//			if (!MultiProtocolAuthenticationHandler.getInstance().isDisableJCifs())
//			{
//				this.impl = new MultiProtocolFile_SMB(path);
//				return;
//			}
//			else
//			{
//				path = "\\\\" + path.substring("smb://".length());
//			}
//		}
		
		this.impl = new MultiProtocolFile_FS(path);
	}
	
	
	
	public MultiProtocolFile(File fsFile) throws IOException
	{
		this.impl = new MultiProtocolFile_FS(fsFile);
	}

	//
	// IMultiProtocolFile
	//
	
	public InputStream getInputStream() throws IOException
	{
		return impl.getInputStream();
	}

	
	public OutputStream getOutputStream() throws IOException
	{
		return impl.getOutputStream();
	}

	public OutputStream getOutputStream(boolean append) throws IOException
	{
		return impl.getOutputStream(append);
	}

	public boolean exists()
	{
		return impl.exists();
	}

	public boolean canRead() throws IOException
	{
		return impl.canRead();
	}

	public boolean canWrite() throws IOException
	{
		return impl.canWrite();
	}

	public long lastModified() throws IOException
	{
		return impl.lastModified();
	}

	public long length() throws IOException
	{
		return impl.length();
	}

	public IMultiProtocolFile[] listFiles() throws IOException
	{
		return impl.listFiles();
	}

	public boolean mkdirs()
	{
		return impl.mkdirs();
	}

	public boolean createNewFile() throws IOException
	{
		return impl.createNewFile();
	}

	public boolean delete()
	{
		return impl.delete();
	}

	public boolean setLastModified(long time)
	{
		return impl.setLastModified(time);
	}

	public long getLastModified()
	{
		return impl.getLastModified();
	}

	public boolean renameTo(IMultiProtocolFile dest) throws IOException
	{
		if (dest instanceof MultiProtocolFile)
			dest = ((MultiProtocolFile)dest).impl;
		
		return impl.renameTo(dest);
	}

	public String getPath()
	{
		return impl.getPath();
	}

	public String getParent()
	{
		return impl.getParent();
	}

	public String getName()
	{
		return impl.getName();
	}

	public boolean isFile() throws IOException
	{
		return impl.isFile();
	}

	public boolean isDirectory() throws IOException
	{
		return impl.isDirectory();
	}
	
	@Override
	public String toString()
	{
		return impl.getPath();
	}
	
}
